import React from "react";
import { Poup, CalendarPicker } from "antd-mobile"
import dayjs from "dayjs"
import { citySetDate } from "../../reducx/city"
import { useDispatch, useDispath } from "react-redux"


function DatePopup({ visible, setVisiblel }) {
    const dispath = useDispatch()

    return (
        <CalendarPicker

            visible={visible}
            selectionMode='single'
            onClose={() => setVisiblel(false)}
            onMaskClick={() => setVisiblel(false)}
            onConfirm={(value) => {
                //dayjs()获取系统当前时间，value是指定的时间
                // format是把时间对象转换成字符串
                const nDate = dayjs(value).format('YYYY-MM-DD')
                dispath(citySetDate(nDate))
            }}


        ></CalendarPicker>
    )
}


export default DatePopup